package com.sino.camunda.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.sino.camunda.domain.User;
import com.sino.camunda.mapper.UserMapper;
import com.sino.camunda.service.CamundaService;
import com.wordnik.swagger.annotations.ApiModel;
import com.wordnik.swagger.annotations.ApiOperation;

@RestController
@ApiModel(value = "啊啊啊啊", description = "测试一下")
public class HomeController {

	@Autowired
	UserMapper userMapper;

	@Autowired
	CamundaService camundaService;

	@RequestMapping("/hello")
	@ApiOperation(value = "Hello word", httpMethod = "GET", response = String.class, notes = "Hello word")
	public String hello(@RequestParam(value = "name", required = false, defaultValue = "camunda") String name) {
		return String.format("Hello %s !", name);
	}

	@RequestMapping("/mapper")
	@ApiOperation(value = "用户列表", httpMethod = "GET", response = User.class, notes = "用户列表")
	public List<User> mapper() {
		return userMapper.selectAll();
	}

	@RequestMapping("/start")
	@ApiOperation(value = "启动流程", httpMethod = "GET", response = String.class, notes = "启动流程")
	private String start() {
		camundaService.start();
		return "Success!";
	}

	@RequestMapping("/json")
	@ApiOperation(value = "JSON测试", httpMethod = "POST", response = Object.class, notes = "JSON测试")
	public User json(@RequestBody User user) {
		return user;
	}

}
